
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="en" data-rank="3">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>${project.name }-VChello Saas</title>
		<link href="/resources/src/css/main.css" rel="stylesheet">
   		<link href="/resources/src/css/responsive.css" rel="stylesheet">
		<link href="/resources/src/css/projects-detail.css" rel="stylesheet">
		<link href="/resources/src/css/projects.css" rel="stylesheet">
	</head>
	<body class="sticky-header left-side-collapsed">
		<jsp:include page="../common/left-slide.jsp" flush="true">
	        <jsp:param name="pageHeader" value="projectHeader" />
	    </jsp:include>
		<div class="main-content">
			<jsp:include page="../common/header-start.jsp" />
        	<div class="row scroll-range" style="margin-right:0; margin-left:0;">
               	<div class="right-box text-center">
               		<!--头部（包含标题和logo等内容）和导航-->
               		<jsp:include page="../common/projects-common.jsp" />
               		
               		<!--标题上传文件-->
               		<input type="hidden" value="${proType}" id="proType" />
               		<input type="hidden" value="${authorization}" id="authorization" />
               		<div class="content-title upload-file">
               			<div id="createFile"><i class="iconfont icon-wenjianshangchuan"></i><span>上传文件</span></div>
               		</div>
               		<!--<c:if test="${proType==0||authorization==1 }">
	               		<div class="content-title upload-file">
	               			<div id="createFile"><i class="iconfont icon-wenjianshangchuan"></i><span>上传文件</span></div>
	               		</div>
               		</c:if>-->
               		<!--主体内容-->
               		<div class="content text-left">
               		<input type="hidden" id="folderId" value="${folder.id }"/>
               			<c:forEach items="${folder.fileList }" var="file">
	               			<div class="list clearfix">
	               				<div class="item file-name pull-left">
	               					<span><a href="${file.url }" title="${file.name }">${file.name }</a></span>	
	               				</div>
	               				<div class="item file-size pull-left">
	               					文件大小&nbsp;:&nbsp;<fmt:formatNumber type="number" value="${file.size/1024 }" pattern="0.00" maxFractionDigits="2"/>M
	               				</div>
	               				<div class="item date-time time pull-left">
	               					上传时间&nbsp;:&nbsp;${file.createTime }
	               				</div>
	               				<div class="pmgressbar-box pull-left">
									<div class="pmgressbar"><span></span></div>
									<div class="pmgressbar-cancel"><i class="iconfont icon-shanchu"></i></div>
								</div>
		               			<div class="item btn-row pull-right">
		               				<a class="reload" data-toggle="tooltip" title="重新上传">
		               					<i class="iconfont icon-shangchuan1" name="fileClass"  id="updateFile_${file.id }"></i>
		               				</a>
		               				<a class="del" data-toggle="tooltip" title="删除文件"  data-value="${file.id }"><i class="iconfont icon-shanchu2"></i></a>
		               			</div>
	               				<%-- <c:if test="${proType==0||authorization==1 }">
		               				<div class="pmgressbar-box pull-left">
										<div class="pmgressbar"><span></span></div>
										<div class="pmgressbar-cancel"><i class="iconfont icon-shanchu"></i></div>
									</div>
		               				<div class="item btn-row pull-right">
		               					<a class="reload" data-toggle="tooltip" title="重新上传">
		               						<i class="iconfont icon-shangchuan1" name="fileClass"  id="updateFile_${file.id }"></i>
		               					</a>
		               					<a class="del" data-toggle="tooltip" title="删除文件"  data-value="${file.id }"><i class="iconfont icon-shanchu2"></i></a>
		               				</div>
	               				</c:if> --%>
	               			</div>
               			</c:forEach>
               		</div>
               	</div>
           </div>
        </div>
        <!--删除确认模态框-->
		<div class="modal fade" id="del-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<input type="hidden" value="" id="del_prpgrass"/>
			<div class="modal-dialog">
				<div class="modal-content text-center">
					<div class="modal-body">
						<div class="text-tip">是否确认删除该文件？</div>
					</div>
					<div class="modal-footer text-center">
						<button type="button" class="btn btn-default cancel" data-dismiss="modal">取消</button>
						<button type="button" class="btn btn-primary confirm" data-dismiss="modal">确认</button>
					</div>
				</div>
			</div>
		</div>
       
        <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
	    <script src="https://cdn.bootcss.com/jquery.nicescroll/3.7.0/jquery.nicescroll.js"></script>
	    <script src="/resources/src/js/bootstrap.min.js"></script>
	    <script src="/resources/src/js/main.js"></script>
	    <script src="/resources/src/js/projects-common.js"></script>
   	    <jsp:include page="/common/plupload/pluploadInclude.jsp"></jsp:include>
	    
	    <script>
	    	$(function(){  
	    	
	    		//上传
	    		$(".re-upload").click(function(){
	    			$(this).parents(".list").find(".pmgressbar-box").show();
	    		});
	    		//取消上传，隐藏上传进度条
	    		$(".content").on("click",".pmgressbar-box .icon-shanchu",function(e){
	    			var e=e || window.event, target=e.target || e.srcElement;
	    			target.parentNode.parentNode.style.display="none";
	    		});
	    		//删除文件按钮,弹出确认框
	    		$(".content").on("click",".del",function(){
	    			$(this).parents(".list").addClass("on").siblings().removeClass("on");
	    			$("#del-modal").modal("show");
	    		});
	    		
	    		//确认删除文件
	    		$("#del-modal .confirm").click(function(){
	    			var id=$(".content .on .del").data("value");
	    			console.log("文件id：" + id);
		    		$.post(
		    				"/file/moveFile",		
		    				{"id":id},
		    				function(data){
		    					if(data.status == true){
			    	    			//删除
			    	    			$(".content .on").remove();
		    					}
			    					//alert(data.data);
		    				},"json"
		    		);
	    		});
	    		
	    		//proFileUpload();
	    		getUserType();
	    		function getUserType(){
	    			var proType=$("#proType").val().trim();
		    		var authorization=$("#authorization").val().trim();	    				
		    		proFileUpload();
	    			/* if(proType=="0" || authorization=="1" ){
	    				proFileUpload();
	    			}else{
	    				$("#createFile").click(function(){
	    					$("#no-permission-modal").modal("show");
	    				});
	    			} */
	    		};
	    		
	    		$("i[name='fileClass']").each(function(){
		    		 againUploadFile($(this).attr("id"));
   				 });
	    	});    
	    	
	    	function proFileUpload(){
  				var clickId = "createFile", //上传按钮id
  				fileName ="uploadFolderFile", //文件对应服务器名字
  				url = '/uploadFile/file',
  				maxFileSize='50mb',//文件最大尺寸
  				FileType='doc,ppt,docx,pptx,pdf',//文件类型
  				progressBar='#bpProgressBar',//文件上传进度条
  				successType='folderFile', //文件处理类型判断，主要用于区分裁剪功能
  				showImgDiv ='#showBpFileName'; //文件上传后，显示在哪个DIV
  				var file = new Array();
  				var fid = $("#folderId").val();
  				file.push(fid);
  				uploadFolderFile(fileName,url,clickId,maxFileSize,FileType,progressBar,successType,showImgDiv, file);//上传BP
   			}
	    	
	    	function againUploadFile(clickIdStr){
				var fileName ="uploadFolderFile", //文件对应服务器名字
				url = '/uploadFile/file',
				maxFileSize='50mb',//文件最大尺寸
				FileType='doc,ppt,docx,pptx,pdf',//文件类型
				progressBar='#bpProgressBar',//文件上传进度条
				successType='folderFile', //文件处理类型判断，主要用于区分裁剪功能
				showImgDiv ='#showBpFileName'; //文件上传后，显示在哪个DIV
				var file = new Array();
				var fid = $("#folderId").val();
				file.push(fid);
				file.push(clickIdStr.split("_")[1]);
				uploadFolderFile(fileName,url,clickIdStr,maxFileSize,FileType,progressBar,successType,showImgDiv, file);//上传BP 
	    	}
	    </script>
       
	</body>
</html>